package com.android.examplelist;

import com.github.johnpersano.supertoasts.SuperActivityToast;
import com.github.johnpersano.supertoasts.SuperCardToast;
import com.github.johnpersano.supertoasts.SuperToast;
import com.github.johnpersano.supertoasts.util.OnClickWrapper;
import com.github.johnpersano.supertoasts.util.OnDismissWrapper;
import com.github.johnpersano.supertoasts.util.Wrappers;

import android.app.ActionBar;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

public class ActionBarActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.actionbar);
		
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		
		actionBar.setSubtitle("Inbox"); 
		actionBar.setTitle("Label:important");
		
		/*
        final Wrappers wrappers = new Wrappers();
        wrappers.add(onClickWrapper);
        wrappers.add(onDismissWrapper);

        SuperCardToast.onRestoreState(savedInstanceState, this,
                wrappers);
		
        
        SuperCardToast superCardToast;
        
        superCardToast = new SuperCardToast(this,
                SuperToast.Type.STANDARD);
        superCardToast.setAnimations(SuperToast.Animations.POPUP);
        
        superCardToast.setText("hahahahah");
        
        superCardToast.show();
        */
		
		SuperActivityToast superActivityToast;
        superActivityToast = new SuperActivityToast(this,
                SuperToast.Type.STANDARD);
        /*
        superActivityToast.setAnimations(SuperToast.Animations.FADE);
        superActivityToast.setDuration(SuperToast.Duration.SHORT);
        superActivityToast.setBackground(SuperToast.Background.BLUE);
        superActivityToast.setTextSize(SuperToast.TextSize.SMALL);
        superActivityToast.setIcon(SuperToast.Icon.Dark.INFO, SuperToast.IconPosition.LEFT);
        */
        superActivityToast.setText("测试....");
        
        superActivityToast.show();
		
	}
	
	
    private OnClickWrapper onClickWrapper = new OnClickWrapper("onclickwrapper_one", new SuperToast.OnClickListener() {

        @Override
        public void onClick(View v, Parcelable token) {

            SuperToast superToast = new SuperToast(v.getContext());
            superToast.setText("onClick!");
            superToast.setDuration(SuperToast.Duration.VERY_SHORT);
            superToast.setBackground(SuperToast.Background.BLUE);
            superToast.setTextColor(Color.WHITE);
            superToast.show();

        }

    });

    private OnDismissWrapper onDismissWrapper = new OnDismissWrapper("ondismisswrapper_one", new SuperToast.OnDismissListener() {

        @Override
        public void onDismiss(View view) {

            SuperToast superToast = new SuperToast(view.getContext());
            superToast.setText("onDismiss!");
            superToast.setDuration(SuperToast.Duration.VERY_SHORT);
            superToast.setBackground(SuperToast.Background.RED);
            superToast.setTextColor(Color.WHITE);
            superToast.show();

        }
    });

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case android.R.id.home:
				finish();
				return true;
			case R.id.action_settings:
				return true;
		}
		
		return super.onOptionsItemSelected(item);
	 }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
